package top.huhuiyu.springboot.study.entity;

import lombok.Data;
import top.huhuiyu.springboot.study.validate.CommonValidator;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * @author 胡辉煜
 */
@Data
public class TestEntity implements Serializable {
  private static final long serialVersionUID = 1L;
  @NotBlank(message = "姓名必须填写", groups = {CommonValidator.Add.class, CommonValidator.Update.class})
  @Pattern(regexp = CommonValidator.USERNAME, message = "姓名第一个必须是字母，后面是字母或者数字或者_，长度为4到16位", groups = {CommonValidator.Add.class, CommonValidator.Update.class})
  private String name;
  @NotNull(message = "年龄必须填写", groups = {CommonValidator.Add.class, CommonValidator.Update.class})
  @Max(value = 200, message = "年龄不超过200", groups = {CommonValidator.Add.class, CommonValidator.Update.class})
  @Min(value = 1, message = "年龄不低于1", groups = {CommonValidator.Add.class, CommonValidator.Update.class})
  private Integer age;
  @NotNull(message = "编号必须填写", groups = {CommonValidator.Update.class})
  private Integer id;
}
